#include <asm.h>
#include <regdef.h>
#include <inst_test.h>

LEAF(n15_sw_test)
    .set noreorder
    addiu s0, s0 ,1
    li  s2, 0x0
###test inst
    TEST_SW(0x61754443, 0x800d77a0,  0x7b14,  0x7b14, 0x61754443)
    TEST_SW(0x5c4fb45a, 0x800d4aac,  0x776c,  0x776c, 0x5c4fb45a)
    TEST_SW(0x14908300, 0x800d4ae8,  0x5bd8,  0x5bd8, 0x14908300)
    TEST_SW(0x516da739, 0x800d60cc, -0x76b0, -0x76b0, 0x516da739)
    TEST_SW(0x85675a34, 0x800d5510,  0x30b0,  0x30b0, 0x85675a34)
    TEST_SW(0x0e4dac98, 0x800db040,  0x4000,  0x4000, 0x0e4dac98)
    TEST_SW(0xd9c6eddb, 0x800d7180,  0x22e0,  0x22e0, 0xd9c6eddb)
    TEST_SW(0x5753dd01, 0x800d2ca0,  0x2780,  0x2780, 0x5753dd01)
    TEST_SW(0xe543b9f3, 0x800d331c,  0x69b8,  0x69b8, 0xe543b9f3)
    TEST_SW(0x4726aca2, 0x800d6cf8,  0x5b70,  0x5b70, 0x4726aca2)
    TEST_SW(0xb022040a, 0x800d0800, -0x5594, -0x5594, 0xb022040a)
    TEST_SW(0x5ca0fd00, 0x800d9834,  0x5070,  0x5070, 0x5ca0fd00)
    TEST_SW(0x063ba000, 0x800d1c64,  0x45fc,  0x45fc, 0x063ba000)
    TEST_SW(0xc2268cfe, 0x800d81e8,  0x5c54,  0x5c54, 0xc2268cfe)
    TEST_SW(0x1611444c, 0x800d0484, -0x1370, -0x1370, 0x1611444c)
    TEST_SW(0x33cc6f2a, 0x800d71dc,  0x2e30,  0x2e30, 0x33cc6f2a)
    TEST_SW(0xc2b46f21, 0x800d1388,  0x6264,  0x6264, 0xc2b46f21)
    TEST_SW(0x63a86040, 0x800d02a8, -0x4550, -0x4550, 0x63a86040)
    TEST_SW(0xe08d45d0, 0x800d1d14, -0x2554, -0x2554, 0xe08d45d0)
    TEST_SW(0xf3839208, 0x800d5308,  0x066c,  0x066c, 0xf3839208)
    TEST_SW(0x4268fd38, 0x800d3f00,  0x03c0,  0x03c0, 0x4268fd38)
    TEST_SW(0x12816280, 0x800d1b94, -0x7560, -0x7560, 0x12816280)
    TEST_SW(0x5404b496, 0x800d1698, -0x1e78, -0x1e78, 0x5404b496)
    TEST_SW(0xf11c1c02, 0x800d1de0, -0x4b38, -0x4b38, 0xf11c1c02)
    TEST_SW(0x31090da2, 0x800d9400,  0x1150,  0x1150, 0x31090da2)
    TEST_SW(0x94809b50, 0x800d27c8,  0x24c0,  0x24c0, 0x94809b50)
    TEST_SW(0xff1ed37c, 0x800d1488, -0x299c, -0x299c, 0xff1ed37c)
    TEST_SW(0x5e23d200, 0x800da074,  0x2558,  0x2558, 0x5e23d200)
    TEST_SW(0x68831248, 0x800d63ec,  0x5f40,  0x5f40, 0x68831248)
    TEST_SW(0x4558e910, 0x800d0cc0,  0x3d8c,  0x3d8c, 0x4558e910)
    TEST_SW(0xc98327b0, 0x800d04e0, -0x57f8, -0x57f8, 0xc98327b0)
    TEST_SW(0xfea2f1ad, 0x800d1b68, -0x5214, -0x5214, 0xfea2f1ad)
    TEST_SW(0xac52b354, 0x800d0000, -0x3c24, -0x3c24, 0xac52b354)
    TEST_SW(0x4f612db4, 0x800d0000,  0x4a74,  0x4a74, 0x4f612db4)
    TEST_SW(0x81e4a52c, 0x800d0000,  0x3370,  0x3370, 0x81e4a52c)
    TEST_SW(0x6b615254, 0x800d0000,  0x729c,  0x729c, 0x6b615254)
    TEST_SW(0x2447d85d, 0x800d0000,  0x7490,  0x7490, 0x2447d85d)
    TEST_SW(0x8dde1c20, 0x800d0000,  0x307c,  0x307c, 0x8dde1c20)
    TEST_SW(0xcf304a09, 0x800d0000, -0x0460, -0x0460, 0xcf304a09)
    TEST_SW(0x431f45e2, 0x800d0000, -0x35a8, -0x35a8, 0x431f45e2)
    TEST_SW(0x99db9a50, 0x800d0000,  0x3248,  0x3248, 0x99db9a50)
    TEST_SW(0xe73f0fdc, 0x800d0000, -0x78e8, -0x78e8, 0xe73f0fdc)
    TEST_SW(0x450bbdc0, 0x800d0000,  0x5128,  0x5128, 0x450bbdc0)
    TEST_SW(0xc0c7c830, 0x800d0000, -0x7680, -0x7680, 0xc0c7c830)
    TEST_SW(0x8006ca23, 0x800d0000,  0x5430,  0x5430, 0x8006ca23)
    TEST_SW(0x40047d98, 0x800d0000, -0x5a18, -0x5a18, 0x40047d98)
    TEST_SW(0xc95de720, 0x800d0000,  0x7c80,  0x7c80, 0xc95de720)
    TEST_SW(0xd0476900, 0x800d0000, -0x3d20, -0x3d20, 0xd0476900)
    TEST_SW(0x873f383a, 0x800d0000,  0x47b8,  0x47b8, 0x873f383a)
    TEST_SW(0x50d54ce0, 0x800d0000, -0x7ce0, -0x7ce0, 0x50d54ce0)
    TEST_SW(0x8502ea18, 0x800d0000, -0x0d10, -0x0d10, 0x8502ea18)
    TEST_SW(0x09f2b630, 0x800d0000, -0x55dc, -0x55dc, 0x09f2b630)
    TEST_SW(0xe8079b47, 0x800d0000,  0x41e0,  0x41e0, 0xe8079b47)
    TEST_SW(0x5de6e330, 0x800d0000,  0x0000,  0x0000, 0x5de6e330)
    TEST_SW(0xbf637404, 0x800d0000,  0x0000,  0x0000, 0xbf637404)
    TEST_SW(0x99227ac0, 0x800d0000,  0x0000,  0x0000, 0x99227ac0)
    TEST_SW(0xddecd270, 0x800d0000,  0x0000,  0x0000, 0xddecd270)
    TEST_SW(0x06a06018, 0x800d0000,  0x0000,  0x0000, 0x06a06018)
    TEST_SW(0xf428d0c8, 0x800d0000,  0x0000,  0x0000, 0xf428d0c8)
    TEST_SW(0xa6ce33ec, 0x800d0000,  0x0000,  0x0000, 0xa6ce33ec)
    TEST_SW(0xa7813bc0, 0x800d0000,  0x0000,  0x0000, 0xa7813bc0)
    TEST_SW(0x72440e8c, 0x800d0000,  0x0000,  0x0000, 0x72440e8c)
    TEST_SW(0xa4130340, 0x800d0000,  0x0000,  0x0000, 0xa4130340)
    TEST_SW(0xb6ca0800, 0x800d0000,  0x0000,  0x0000, 0xb6ca0800)
    TEST_SW(0x17331928, 0x800d0000,  0x0000,  0x0000, 0x17331928)
    TEST_SW(0x09537c5f, 0x800d0000,  0x0000,  0x0000, 0x09537c5f)
    TEST_SW(0x36964fd0, 0x800d0000,  0x0000,  0x0000, 0x36964fd0)
    TEST_SW(0xe67b1aa6, 0x800d0000,  0x0000,  0x0000, 0xe67b1aa6)
    TEST_SW(0x00000000, 0x800d0000,  0x0000,  0x0000, 0x00000000)

###detect exception
    bne s2, zero, inst_error
    nop
###score ++
    addiu s3, s3, 1
###output (s0<<24)|s3
inst_error:  
    sll t1, s0, 24
    NOP4
    or t0, t1, s3 
    NOP4
    sw t0, 0(s1)
    jr ra
    nop
END(n15_sw_test)
